package com.boesch.electroOffice.utils;

import java.io.Serializable;

import org.springframework.stereotype.Component;

import com.liferay.faces.portal.context.LiferayFacesContext;
import com.liferay.portal.model.Theme;
import com.liferay.portal.theme.ThemeDisplay;

@Component
public class LiferayUtils implements Serializable {

	private static final long serialVersionUID = 2701760651409988211L;

	public static LiferayFacesContext getLiferayFacesContext() {
		return LiferayFacesContext.getInstance();
	}

	/**
	 * Returns the Liferay {@link Theme} associated with the Liferay {@link LiferayFacesContext}.
	 * 
	 * @return Theme theme
	 */
	public static Theme getTheme() {
		return getLiferayFacesContext().getTheme();
	}

	/**
	 * Returns the Liferay {@link ThemeDisplay} associated with the {@link LiferayFacesContext}.
	 * 
	 * @return ThemeDisplay themeDisplay
	 */
	public static ThemeDisplay getThemeDisplay() {
		return getLiferayFacesContext().getThemeDisplay();
	}

	/**
	 * Returns the current Liferay groupId {@link Group} associated with the {@link Layout}.
	 * 
	 * @return long currentGroupId
	 */
	public static long getCurrentGroupId() {
		return getThemeDisplay().getLayout().getGroupId();
	}

	public boolean isSignedIn() {
		return getThemeDisplay().isSignedIn();
	}

	public boolean isNotSignedIn() {
		return !isSignedIn();
	}
}
